<?php
namespace core\lib;
/**
* config
*/
class config
{
	public static $config = [];
	public static function get($file, $name = null)
	{
		//1.判断配置文件是否存在
		//2.判断配置是否存在
		//3.缓存配置
		if (isset(self::$config[$file])) {
			if (isset($name)) {
				return self::$config[$file][$name];
			} else {
				return self::$config[$file];
			}
		} else {
			$path = MYFW . '/core/config/' . $file . '.php';
			if (is_file($path)) {
				$config = include $path;
				self::$config[$file] = $config;
				if (isset($name)) {
					if (isset($config[$name])) {
						return self::$config[$file][$name];
					} else {
						throw new Exception('没有这个配置项', $name);
					}
				} else {
					return self::$config[$file];
				}
			} else {
				throw new Exception("找不到配置文件", $file);
			}
		}
	}
}